<!---
	Copyright 2010 Edward Trudeau, Jeremy Battle
    This software is freely available under the MIT License: http://www.opensource.org/licenses/mit-license.php
    http://ayc.googlecode.com
    
--->

<cfcomponent name="AgenciesService" output="false" extends="_AgenciesService">
	
    <cfset variables.objectInstance = structNew() />
	

	<cffunction name="init" access="public" output="false" returntype="AgenciesService">
		<cfargument name="AgenciesDAO" type="AgenciesDAO" required="true" />
		<cfargument name="AgenciesGateway" type="AgenciesGateway" required="true" />

		<cfset super.init(arguments.AgenciesDAO, arguments.AgenciesGateway) />

		<cfreturn this/>
	</cffunction>
    
    <cffunction name="getAgenciesSelect" access="public" output="no" returntype="string">
    	<cfargument name="selectedItem" required="no" type="string" hint="The item to show as selected, typically an id or character string" />
        
        <cfset var qAgencies = variables.AgenciesGateway.getAgencySelect() />
        <cfset var i = 0 />
        <cfset var outStr = "" />
        
        <cfoutput query="qAgencies">
        	<cfset outStr = outStr & '<option value="#qAgencies.Id#"' />
        	<cfif structKeyExists(arguments, "selectedItem") AND trim(arguments.selectedItem) EQ qAgencies.Id>
            	<cfset outStr = outStr & ' selected="selected"' />
            </cfif>
            <cfset outStr = outStr & '>#qAgencies.Name#</option>' />
        </cfoutput>
       
       <cfreturn outStr />
    </cffunction>
    
    <cffunction name="getGateway" access="public" output="false" returntype="AgenciesGateway">
    	<cfreturn variables.AgenciesGateway />
    </cffunction>
    
    
    <cffunction name="getDAO" access="public" output="false" returntype="AgenciesDAO">
    	<cfreturn variables.AgenciesDAO />
    </cffunction>
</cfcomponent>


